import { ref } from 'vue'
import { GetOrderListParam } from '../types'
import { getOrderList } from '@/api/order'

// 获取工单列表加载
const getOrderListLoading = ref(false)

// 工单列表
const orderList = ref<Array<OrderListItem>>([])

// 列表总条数
const total = ref(0)

// 获取工单列表方法
const getOrderListFn = async (data: GetOrderListParam) => {
  getOrderListLoading.value = true
  const res = await getOrderList(data)
  getOrderListLoading.value = false
  if (res.data.code === 20000) {
    orderList.value = res.data.data.rows
    total.value = Number(res.data.data.total)
  }
}

export default {
  total,
  orderList,
  getOrderListLoading,
  getOrderListFn,
}
